﻿@{
    ViewBag.Title = "About";
}
@section styles{
    <link rel="stylesheet" type="text/css" href="~/Content/ABOUT.css" />
}


<from>
    <button id="pdf">生成报价单</button>
    <button> @Html.ActionLink("返回", "Quotation_to_be_generated", new { Controller = "Home", Action = "Quotation_to_be_generated" }, new { @class = "", @style = "" })</button>
    <div style="display:none" id="BJD_App_bian">@(Session["BJD_App_bian"])</div>
</from>
<from >
    <div style="width: 801px; background-color: white" id="HTML">
        <div id="BJD_bigdiv" style="border: 1px solid black; padding: 5px">
            <div style="text-align:center"><h3>QUOTATION PROPOSAL</h3></div>
            <div id="DJD_gs_xx" style="width:100%">
                <table style="font-size: 10px; font-weight: bolder ;width:100%">
                    <tr>
                        <td style="width:70%;height:17px;"><div>IPS LANDO</div></td>
                        <td rowspan="5" style="width: 25%; height: 75px;" id="img_diz">
                            <img  src="~/img/Landuo_biao.png" id="IMG_landuo" style="width:75%;height:75%"/>
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 70%; height: 17px;"><div>No 80, Shuang Ma Rd,Weiting SIP</div></td>
                        
                    </tr>
                    <tr>
                        <td style="width: 70%; height: 17px;"><div>Suzhou</div></td>
                    </tr>
                    <tr>
                        <td style="width: 70%; height: 17px;"><div>Jiangsu,215121,China</div></td>
                    </tr>
                    <tr>
                        <td style="width: 70%; height: 17px;"><div>Tel (86) 512 6272 3215 Fax (86) 512 6272 3216</div></td>
                    </tr>
                </table>
            </div>
            <div>
                <table style="width: 100%; border: 1.5px solid black; margin-top: 10px; font-size: 14px">
                    <tr>
                        <td style="width: 20%" colspan="2">Our Quotation Reference:</td>
                        <td style="width: 20%" colspan="2" id="BJ_ld_a0"></td>
                    </tr>
                    <tr>
                        <td style="width: 20%">Quotation Date:</td>
                        <td style="width: 20%" id="BJ_ld_a1"></td>
                        <td style="width: 20%">No of Parts Quoted:</td>
                        <td style="width: 20%" id="BJ_ld_a2"></td>
                    </tr>
                    <tr>
                        <td style="width: 20%">Quotation Prepared By:</td>
                        <td style="width: 20%" id="BJ_ld_a3"></td>
                        <td style="width: 20%">Contact Details:</td>
                        <td style="width: 20%" id="BJ_ld_a4"></td>
                    </tr>
                </table>
            </div>
            <div>
                <table style="width: 100%; border: 1.5px solid black; margin-top: 10px; font-size: 14px">
                    <tr>
                        <td style="width: 20%" colspan="2">Contact Person:</td>
                        <td style="width: 20%" colspan="2" id="BJ_kh_b0"></td>
                    </tr>
                    <tr>
                        <td style="width: 20%">Customer:</td>
                        <td style="width: 20%" id="BJ_kh_b1"></td>
                        <td style="width: 20%">E-mail:</td>
                        <td style="width: 20%" id="BJ_kh_b2"></td>
                    </tr>
                    <tr>
                        <td style="width: 20%">Telephone:</td>
                        <td style="width: 20%" id="BJ_kh_b3"></td>
                        <td style="width: 20%">Fax:</td>
                        <td style="width: 20%" id="BJ_kh_b4"></td>
                    </tr>
                    <tr>
                        <td style="width: 20%">Address:</td>
                        <td style="width: 20%" id="BJ_kh_b5"></td>
                        <td style="width: 20%"></td>
                        <td style="width: 20%"></td>
                    </tr>
                </table>
            </div>
            <div>
                <table style="width: 100%; border: 1.5px solid black; margin-top: 10px; font-size: 14px">
                    <tr>
                        <td style="width: 20%">Product:</td>
                        <td style="width: 20%"></td>
                        <td style="width: 20%"></td>
                        <td style="width: 20%"></td>
                    </tr>
                    <tr>
                        <td style="width: 20%">Customer Ref:</td>
                        <td style="width: 20%" id="BJ_cp_c1"></td>
                        <td style="width: 20%">Pack Style:</td>
                        <td style="width: 20%" id="BJ_cp_c2"></td>
                    </tr>
                    <tr>
                        <td style="width: 20%">Dimensions:</td>
                        <td style="width: 20%" id="BJ_cp_c3"></td>
                        <td style="width: 20%"></td>
                        <td style="width: 20%"></td>
                    </tr>
                </table>
            </div>
            <div>
                <table style="width: 100%; border: 1.5px solid black; margin-top: 10px; font-size: 14px">
                    <tr>
                        <td style="width: 20%">Delivery Term:</td>
                        <td style="width: 20%" id="BJ_fk_d1"></td>
                        <td style="width: 20%">Lead Time:</td>
                        <td style="width: 20%" id="BJ_fk_d2"></td>
                    </tr>
                    <tr>
                        <td style="width: 20%">Payment Terms:</td>
                        <td style="width: 20%" id="BJ_fk_d3"></td>
                        <td style="width: 20%"></td>
                        <td style="width: 20%"></td>
                    </tr>
                </table>
            </div>
            <div>
                <table style="width: 100%; border: 1.5px solid black; margin-top: 10px; font-size: 14px">
                    <thead>
                        <tr>
                            <td style="width: 16%">ItemNo.</td>
                            <td style="width: 16%">Item Name</td>
                            <td style="width: 16%">Specifications</td>
                            <td style="width: 16%">MOQ</td>
                            <td style="width: 16%">Unit</td>
                            <td style="width: 16%">IPS Lando Selling Price in RMB(Inclu Tax)</td>
                            <td style="width: 16%">Remarks</td>
                        </tr>
                    </thead>
                    <tbody id="BB_Bom_td">
                    </tbody>
                </table>
            </div>
            <div>
                <table style="width: 100%; border: 1.5px solid black; margin-top: 10px; font-size: 14px ">
                    <thead>
                        <tr>
                            <td style="text-align:center;font-size:150%">Remarks</td>
                        </tr>
                    </thead>
                    <tbody id="BB_Re_tb">
                    </tbody>
                </table>
            </div>
        </div>
    </div>

</from>


@section scripts
{
    <script src="~/Scripts/jquery-3.4.1.min.js"></script>
    <script src="~/Scripts/bootstrap.min.js"></script>
    <script>
        $(function () {
            var App_bian = $("#BJD_App_bian").text()
            Downpdf()
            getAll()
            GetBom()

            //打印PDF报价单
            function Downpdf() {
                $(document).on("click", "#pdf", function () {
                    $("#IMG_landuo").remove()
                    var Employee_path = $("#Login_path").text()
                    var htmlContent2 = $('#HTML').html()
                    console.log(Employee_path)
                    var userInput = prompt("请输入文件名：", "");
                    if (userInput != null) {
                        $.ajax({
                            url: '/Home/About',
                            type: 'POST',
                            data: { "state": 1, "Pdfname": userInput, "htmlContent2": htmlContent2, "Employee_path": Employee_path },
                            success: function (pdf) {
                                alert("下载成功")
                                $("#img_diz").append(`<img  src="~/img/Landuo_biao.png" id="IMG_landuo" style="width:75%;height:75%"/>`)
                            },
                            error: function () {
                                alert('Request Error');
                            }
                        })
                    }

                })
            }
            //获取客户报价单信息
            function getAll() {
                $.ajax({
                    url: '/Home/About',
                    type: 'POST',
                    data: { "state": 2, "App_bian": App_bian },
                    success: function (qwerf) {
                        Add_data(qwerf)
                        console.log(qwerf)
                    },
                    error: function () {
                        alert('Request Error');
                    }
                })
            }
            function Add_data(data) {
                $("#BB_Re_tb tr")
                $.each(data, function (i, item) {
                    //兰多
                    $("#BJ_ld_a0").text(item.APP_name)
                    $("#BJ_ld_a1").text(item.App_qishi)
                    $("#BJ_ld_a2").text(item.AP_ren)
                    $("#BJ_ld_a3").text()
                    $("#BJ_ld_a4").text()
                    //客户
                    $("#BJ_kh_b0").text(item.APP_Zhong)
                    $("#BJ_kh_b1").text(item.CL_name)
                    $("#BJ_kh_b2").text(item.CL_you)
                    $("#BJ_kh_b3").text(item.CL_lian)
                    $("#BJ_kh_b4").text()
                    $("#BJ_kh_b5").text(item.App_dizhi)
                    //产品
                    $("#BJ_cp_c1").text(item.CL_bian)
                    $("#BJ_cp_c2").text()
                    $("#BJ_cp_c3").text()
                    //付款
                    $("#BJ_fk_d1").text()
                    $("#BJ_fk_d2").text()
                    $("#BJ_fk_d3").text(item.App_sho)
                    if (item.App_bei != "") {
                        var $xxx = $(`
                                          <tr>
                                              <td>${item.App_bei}</td>
                                          </tr>
                                      `);
                        $('#BB_Re_tb').append($xxx);
                    }
                })
            }
            //获取项目BOM信息
            function GetBom() {
                $.ajax({
                    url: '/Home/About',
                    type: 'POST',
                    data: { "state": 3, "App_bian": App_bian },
                    success: function (data) {
                        Add_bom(data)
                    },
                    error: function () {
                        alert('Request Error');
                    }
                })
            }
            function Add_bom(data) {
                $("#BB_Bom_td tr").remove()
                $.each(data, function (i, item) {
                    var $xxx = $(`
                                            <tr>
                                                <td style="width: 16%">${i + 1}</td>
                                                <td style="width: 16%">${item.BOM2_wuLiu}</td>
                                                <td style="width: 16%">${item.BOM2_Guige}</td>
                                                <td style="width: 16%">${item.BOM2_Nian}</td>
                                                <td style="width: 16%">${item.Nd_danwei}</td>
                                                <td style="width: 16%">${item.Nd_jiage}</td>
                                                <td style="width: 16%"></td>
                                            </tr>
                                        `);
                    $('#BB_Bom_td').append($xxx);
                })
            }
        })

    </script>

}